package yns.springboot.security.sample.security.config;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Component;

@Component
public class SecurityUserHelper {

	public UserDetails getCurrentUserDetails() {
		UserDetails userDetails = (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		
		return userDetails;
	}

	public Object[] getCurrentUserAuthentication() {
	
		Object[] authorities = getCurrentUserDetails().getAuthorities().toArray();
		
		return authorities;
	}
}

